#ifndef SUPPORT_STRUCTS_HPP
#define SUPPORT_STRUCTS_HPP

// include my own libraries now...
// after failing to find one that suits my needs
#include ".\geometry\Vec3.hpp"
#include ".\geometry\Vec2.hpp"

#ifndef EPSILON
#define EPSILON 0.0001f
#endif

// 3D vector types
typedef VEC3<float>     Vec3f;
typedef VEC3<double>    Vec3d;
typedef VEC3<int>       Vec3i;

// 2D vector types
typedef VEC2<float>    Vec2f;
typedef VEC2<double>    Vec2d;
typedef VEC2<int>       Vec2i;

typedef unsigned int     uint;

typedef unsigned char  ubyte;    // unsigned byte for storing 0..255 numbers
typedef signed char    sbyte;    // signed byte for storing -128..127 numbers

// A all-encompassing mesh structure : this is only for temporary storage
// it is not to be used for copying directly to VBOs
// If other vertex structs are added, any new properties they hold
// should also be copied here
struct general_vertex
{
    general_vertex(): pos(0.0), norm(0.0), alphas(0.0f), mats(0), intensity(0) { }
    Vec3d pos;
    Vec3d norm;
    Vec3f alphas;
    VEC3<ubyte> mats;
    ubyte intensity;
};

// general face stucture, also should not be used directly
struct general_face
{
    general_face() : verts(-1) {}
    Vec3i verts;
};

// Mesh structures
// NOTE: we try to keep structure size multiple of 32
// this struct is 64 bytes (double = 8 bytes, float = 4 bytes, ubyte = 1 bytes)
struct mesh_vertex
{
    mesh_vertex (): x(0), y(0), z(0), nx(0), ny(0), nz(0), m1(0), m2(0), m3(0), a1(0), a2(0), a3(0) { }
    double x, y, z;            // vertex position    
    double nx, ny, nz;        // vertex normal std::vector    
    float a1, a2, a3;       // alpha to blend textures (for multi-texturing)    
    ubyte m1, m2, m3;        // materials for 3 vertices that create a triangle
    ubyte i;                // colour intensity
};            

struct water_vertex
{
    water_vertex() : x(0.0), y(0.0), z(0.0), nx(0.0), ny(0.0), nz(0.0) { }
    double x,y,z;
    double nx, ny, nz;  // normal vector
    double tx, ty, tz;  // tangent vector
};

struct mesh_edge
{
    int v1, v2;
    int f1, f2;
};

struct mesh_face
{
    mesh_face() : v1(0), v2(0), v3(0) { }
    unsigned short v1, v2, v3;            // 3 vertecies per face, no per-face normal
};                            // struct size is 3 * 2bytes = 6 bytes

#endif
